package com.fivestar.pmanager.dao.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.fivestar.pmanager.core.mapper.DBActionMapper;
import com.fivestar.pmanager.core.mapper.PaginatingMapper;
import com.fivestar.pmanager.model.SysDictBean;

import java.util.List;
import java.util.Map;

/**
 * 系统字典
 * SysDictMapper
 * @author 
 *
 */
@Repository("sysDictMapper")
public interface SysDictMapper extends DBActionMapper<SysDictBean>,
        PaginatingMapper<SysDictBean>
{


    @Select("select code,value from sys_dict where name = #{name} and is_deleted='0'")
    @ResultMap("BaseResultMap")
    List<SysDictBean> findByName(String name);
 

    @Select("select code,value from sys_dict where name = #{name} and code=#{code} and is_deleted='0'")
    @ResultMap("BaseResultMap")
    SysDictBean findByNameAndCode(@Param("name")String name, @Param("code")String code);
    
    
    /**
     * 查询并返回listmap
     *
     * @param SysDictBean 查询条件
     * @return List<Map<String,Object>>
     */
    @Results({
            @Result(column = "rid", property = "id"),
            @Result(column = "value", property = "text")
    })
    @Select("SELECT mca.row_id rid,sd.value value FROM sys_dict sd INNER JOIN md_community_area mca on sd.code=mca.type where sd.name='COMMUNITY_AREA_TYPE' and value like '%${value}%'")
    List<Map<String,Object>> findForSearch(SysDictBean sysDictBean);


    
}
